package com.wlhse.controller;

import com.wlhse.entity.RouteTaskPojo;
import com.wlhse.service.RouteTaskService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController("RouteTaskController")
@RequestMapping("/api/v1")
//巡检
public class RouteTaskController {

    @Resource
    private RouteTaskService routeTaskService;

    @Resource
    private RouteTaskPojo routeTaskPojo;

    @RequestMapping(value = "/route_task", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    public String getAllRoute_task(@ModelAttribute RouteTaskPojo routeTaskPojo) {
            return routeTaskService.selectRouteTask(routeTaskPojo);
    }

    @RequestMapping(value = "/route_task/{id}", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    public String getRoute_task(@PathVariable int id) {
            return routeTaskService.selectRouteTaskById(id);
    }

    @RequestMapping(value = "/route_task/{id}", method = RequestMethod.DELETE, produces = "application/json; charset=utf-8")
    public String addRoute_task(@PathVariable int id) {
            routeTaskPojo.setRouteTaskId(id);
            return routeTaskService.deleteRouteTask(routeTaskPojo);
    }

    @RequestMapping(value = "/route_task/{id}", method = RequestMethod.PUT, produces = "application/json; charset=utf-8")
    public String updateRoute_task(@RequestBody(required = false) RouteTaskPojo routeTaskPojo, @PathVariable int id) {
            routeTaskPojo.setRouteTaskId(id);
            return routeTaskService.updateRouteTask(routeTaskPojo);
    }

    @RequestMapping(value = "/route_task", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    public String updateRoute_task(@RequestBody(required = false) RouteTaskPojo routeTaskPojo) {
            return routeTaskService.insertRouteTask(routeTaskPojo);
    }

}